﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Newtonsoft.Json;
using System.Net;
using System.IO;

public partial class info : System.Web.UI.Page
{
    public BusAnnouncementDetail detail;
    protected void Page_Load(object sender, EventArgs e)
    {
        HttpWebRequest request = (HttpWebRequest)WebRequest.Create(String.Format("http://api.joyspots.net/service/ann.aspx?annid={0}", Request.Cookies["JoySpots"].Values["rtid"]));
            request.Method = "GET";

            using (WebResponse response = request.GetResponse())
            {
                using (StreamReader sr = new StreamReader(response.GetResponseStream(), System.Text.Encoding.UTF8))
                {
                    BusAnnouncement ann = (BusAnnouncement)JsonConvert.DeserializeObject(sr.ReadToEnd(), typeof(BusAnnouncement));
                    detail = ann.announcement[0];
                    DateTime DT = Convert.ToDateTime(detail.ins_datetime);
                    AnnoceTime.Text = string.Format("{0}年{1}月{2}日", DT.Year, DT.Month, DT.Day);
                }
            }
        }
    
     public class BusAnnouncement
    {
        public List<BusAnnouncementDetail> announcement;
    }

    public class BusAnnouncementDetail
    {
        public string id;
        public string title;
        public string content;
        public string ins_datetime;
        public string upd_datetime;
    }
}